package com.exposit.books.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Table (name="preorders")
public class PreOrders {
	private Long id;
	private List<Order> preOrders;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "preorders_id")
	@PrimaryKeyJoinColumn
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "preOrders")
	@Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
	public List<Order> getPreOrders() {
		return preOrders;
	}
	public void setPreOrders(List<Order> preOrders) {
		this.preOrders = preOrders;
	}
}
